package com.example.administrator.dagger2demo.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.dagger2demo.R;
import com.example.administrator.dagger2demo.adapter.inter.Indo;
import com.example.administrator.dagger2demo.adapter.inter.WorkAdapter;

import java.util.ArrayList;

import in.srain.cube.views.ptr.PtrClassicFrameLayout;

/**
 * Created by Administrator on 2015/11/18.
 */
public class FragmentII extends BaseLazyLoadFragment {
    RecyclerView workRecyclerView;
    WorkAdapter workAdapter;
    PtrClassicFrameLayout mPtrFrame;
    ArrayList<Indo> indos = new ArrayList<>();

    public static FragmentII newInstance(Bundle args) {
        FragmentII pageFragment = new FragmentII();
        pageFragment.setArguments(args);
        return pageFragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        //1.
        super.onCreate(savedInstanceState);
        Log.e("TAG", "onCreate=II");
    }


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //2.
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_ii, container, false);
        isPrepared = true;
        Log.e("TAG", "onCreateView-II");
        lazyLoad();//这里我们调用以下去加载我们的数据
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        //3.
        Log.e("TAG", "onViewCreated=II");

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e("TAG", "onDestroy-end-II");
    }

    //标志位，标志已经初始化完成。
    private boolean isPrepared;

    @Override
    protected void lazyLoad() {
        if (isPrepared && isVisible) {
            //网络请求加载....
            Log.e("TAG", "lazyLoad-if-II");

            isPrepared = false;

        }
        Log.e("TAG", "lazyLoad-II-end");
    }
}
